package bdz.framework.web.vo
{
	import com.adobe.crypto.SHA1;
	
	import flash.events.EventDispatcher;
	public class BDZWFUser extends EventDispatcher
	{
		private static var instance:BDZWFUser;
		private var _source:XML;
		public function BDZWFUser(se:SingletonEnforcer)
		{
			super();
		}
		public static function getUser(xm:XML = null):BDZWFUser{
			if(!instance){
				instance = new BDZWFUser(new SingletonEnforcer());
				instance.initialize(xm);
			}
			return instance;
		}
		private function initialize(xm:XML):void{
			if(xm){
				_source = xm.df_users[0];
			}else{
				_source = new XML("<df_users/>");
			}
		}
		public function get username():String{
			return _source.username;	
		}
		public function set username(str:String):void{
			_source.username = str;	
		}
		public function get account_type():Number{
			return Number(_source.account_type.toString());
		}
		public function set account_type(n:Number):void{
			_source.account_type = n;
		}
		public function get password():String{
			return _source.password.toString();
		}
		public function set password(str:String):void{
			_source.password = SHA1.hash(str);	
		}
		public function get displayname():String{
			return _source.displayname.toString();
		}
		public function set displayname(str:String):void{
			_source.displayname = str;	
		}
		public function get email():String{
			return _source.email.toString();
		}
		public function set email(str:String):void{
			_source.email = str;	
		}
		public function get definition():XML{
			return _source.definition;
		}
		public function set definition(xm:XML):void{
			_source.definition = xm;
		}
		public function get token():String{
			return _source.token.toString();
		}
		public function get source():XML{
			return _source;
		}
		
	}
}
/**
 * @private
 * 
 */
internal class SingletonEnforcer{}